import { useLoginStore } from "@/stores/login"


const countryNameList = [
  '连平县','陆河县'
]

export function loginSuccess(res){
  const loginStore = useLoginStore()
  loginStore.setData(res.data.data)
  loginStore.setLoginData({ username: '', password: '' })
  let url = ''
  if (loginStore.user.authority === 1) {
    url = 'director'
  }
  else if (loginStore.user.authority === 2) {
    if (countryNameList.includes(loginStore.user.unit) ) {
      url = 'xian'
    }
    else url = 'unit'
  }
  else {
    url = 'school'
  }
  window.location.href = window.location.href.replace(/(^[^\\/]*\/\/[^\\/]*\/).*$/, '$1' + url);
}